/**
 * 
 */
package com.dalonedrau.graph;

import java.util.Comparator;

/**
 * @author DaLoneDrau
 */
public final class DijkstraComparator implements Comparator<Integer> {
	/** the search instance. */
	private DijkstraSearch	search;
	/**
	 * Creates a new instance of {@link DijkstraComparator}.
	 * @param s the search instance
	 */
	public DijkstraComparator(final DijkstraSearch s) {
		super();
		search = s;
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public int compare(final Integer o1, final Integer o2) {
		int val = 0;
		float distance1 = search.getDistances()[o1];
		float distance2 = search.getDistances()[o2];
		if (distance1 < distance2) {
			val = -1;
		} else if (distance1 > distance2) {
			val = 1;
		}
		return val;
	}

}
